package com.jzy.interceptor.config;


import com.jzy.interceptor.BaseInterceptor;
import com.jzy.util.TaleUtils;
import org.springframework.context.annotation.Configuration;
import org.springframework.web.servlet.config.annotation.InterceptorRegistry;
import org.springframework.web.servlet.config.annotation.WebMvcConfigurer;

import javax.annotation.Resource;

/**
 * 向mvc中添加自定义组件
 * Created by BlueT on 2017/3/9.
 */
@Configuration
public class WebMvcConfig implements WebMvcConfigurer {
    @Resource
    private BaseInterceptor baseInterceptor;


    /**
     * 添加静态资源文件，外部可以直接访问地址
     * @param registry
     */
    //,"file:"+ TaleUtils.getUploadFilePath()+"upload/"
    @Override
    public void addInterceptors(InterceptorRegistry registry) {
        registry.addInterceptor(baseInterceptor).excludePathPatterns("/upload/**", "/**/*.js", "/**/*.css", "/**/*.png", "/**/*.jpg");
    }


}
